\hypertarget{classaetycoon_1_1_choice_property}{
\section{aetycoon.ChoiceProperty Class Reference}
\label{classaetycoon_1_1_choice_property}\index{aetycoon::ChoiceProperty@{aetycoon::ChoiceProperty}}
}
\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
def \hyperlink{classaetycoon_1_1_choice_property_a1a4ba31c662ea4744edbe5e8b0cdc1ca}{\_\-\_\-init\_\-\_\-}
\item 
def \hyperlink{classaetycoon_1_1_choice_property_afe3ec218220685bfcd03fe7f312596a9}{get\_\-choices}
\item 
def \hyperlink{classaetycoon_1_1_choice_property_ab3fa454e82c3f5e55b1763ffcff18e5a}{c2i}
\item 
\hypertarget{classaetycoon_1_1_choice_property_ae45c46f3f68fb21bb13d44a7c7e24527}{
def {\bfseries \_\-\_\-get\_\-\_\-}}
\label{classaetycoon_1_1_choice_property_ae45c46f3f68fb21bb13d44a7c7e24527}

\item 
\hypertarget{classaetycoon_1_1_choice_property_aa33a24eca53613b934c0afd7e349dc14}{
def {\bfseries \_\-\_\-set\_\-\_\-}}
\label{classaetycoon_1_1_choice_property_aa33a24eca53613b934c0afd7e349dc14}

\item 
\hypertarget{classaetycoon_1_1_choice_property_a6cafae9dbccf6ff768b76cf9ac102ed5}{
def {\bfseries get\_\-value\_\-for\_\-datastore}}
\label{classaetycoon_1_1_choice_property_a6cafae9dbccf6ff768b76cf9ac102ed5}

\item 
\hypertarget{classaetycoon_1_1_choice_property_a7957847c7a9f7747a82b754149e0a56f}{
def {\bfseries make\_\-value\_\-from\_\-datastore}}
\label{classaetycoon_1_1_choice_property_a7957847c7a9f7747a82b754149e0a56f}

\end{DoxyCompactItemize}
\subsection*{Public Attributes}
\begin{DoxyCompactItemize}
\item 
\hypertarget{classaetycoon_1_1_choice_property_a56a46e9df09568f6ca180ebe23b2848f}{
{\bfseries index\_\-to\_\-choice}}
\label{classaetycoon_1_1_choice_property_a56a46e9df09568f6ca180ebe23b2848f}

\item 
\hypertarget{classaetycoon_1_1_choice_property_a14a82ca861a3c77194e7977875bef83d}{
{\bfseries choice\_\-to\_\-index}}
\label{classaetycoon_1_1_choice_property_a14a82ca861a3c77194e7977875bef83d}

\end{DoxyCompactItemize}


\subsection{Detailed Description}
\begin{DoxyVerb}A property for efficiently storing choices made from a finite set.

This works by mapping each choice to an integer.  The choices must be hashable
(so that they can be efficiently mapped back to their corresponding index).

Example usage:

>>> class ChoiceModel(db.Model):
...   a_choice = ChoiceProperty(enumerate(['red', 'green', 'blue']))
...   b_choice = ChoiceProperty([(0,None), (1,'alpha'), (4,'beta')])

You interact with choice properties using the choice values:

>>> model = ChoiceModel(a_choice='green')
>>> model.a_choice
'green'
>>> model.b_choice == None
True
>>> model.b_choice = 'beta'
>>> model.b_choice
'beta'
>>> model.put() # doctest: +ELLIPSIS
datastore_types.Key.from_path(u'ChoiceModel', ...)

>>> model2 = ChoiceModel.all().get()
>>> model2.a_choice
'green'
>>> model.b_choice
'beta'

To get the int representation of a choice, you may use either access the
choice's corresponding attribute or use the c2i method:
>>> green = ChoiceModel.a_choice.GREEN
>>> none = ChoiceModel.b_choice.c2i(None)
>>> (green == 1) and (none == 0)
True

The int representation of a choice is needed to filter on a choice property:
>>> ChoiceModel.gql("WHERE a_choice = :1", green).count()
1
\end{DoxyVerb}
 

\subsection{Constructor \& Destructor Documentation}
\hypertarget{classaetycoon_1_1_choice_property_a1a4ba31c662ea4744edbe5e8b0cdc1ca}{
\index{aetycoon::ChoiceProperty@{aetycoon::ChoiceProperty}!\_\-\_\-init\_\-\_\-@{\_\-\_\-init\_\-\_\-}}
\index{\_\-\_\-init\_\-\_\-@{\_\-\_\-init\_\-\_\-}!aetycoon::ChoiceProperty@{aetycoon::ChoiceProperty}}
\subsubsection[{\_\-\_\-init\_\-\_\-}]{\setlength{\rightskip}{0pt plus 5cm}def aetycoon.ChoiceProperty.\_\-\_\-init\_\-\_\- (
\begin{DoxyParamCaption}
\item[{}]{self, }
\item[{}]{choices, }
\item[{}]{make\_\-choice\_\-attrs = {\ttfamily True}, }
\item[{}]{args, }
\item[{}]{kwargs}
\end{DoxyParamCaption}
)}}
\label{classaetycoon_1_1_choice_property_a1a4ba31c662ea4744edbe5e8b0cdc1ca}
\begin{DoxyVerb}Constructor.

Args:
  choices: A non-empty list of 2-tuples of the form (id, choice). id must be
the int to store in the database.  choice may be any hashable value.
  make_choice_attrs: If True, the uppercase version of each string choice is
set as an attribute whose value is the choice's int representation.
\end{DoxyVerb}
 

\subsection{Member Function Documentation}
\hypertarget{classaetycoon_1_1_choice_property_ab3fa454e82c3f5e55b1763ffcff18e5a}{
\index{aetycoon::ChoiceProperty@{aetycoon::ChoiceProperty}!c2i@{c2i}}
\index{c2i@{c2i}!aetycoon::ChoiceProperty@{aetycoon::ChoiceProperty}}
\subsubsection[{c2i}]{\setlength{\rightskip}{0pt plus 5cm}def aetycoon.ChoiceProperty.c2i (
\begin{DoxyParamCaption}
\item[{}]{self, }
\item[{}]{choice}
\end{DoxyParamCaption}
)}}
\label{classaetycoon_1_1_choice_property_ab3fa454e82c3f5e55b1763ffcff18e5a}
\begin{DoxyVerb}Converts a choice to its datastore representation.\end{DoxyVerb}
 \hypertarget{classaetycoon_1_1_choice_property_afe3ec218220685bfcd03fe7f312596a9}{
\index{aetycoon::ChoiceProperty@{aetycoon::ChoiceProperty}!get\_\-choices@{get\_\-choices}}
\index{get\_\-choices@{get\_\-choices}!aetycoon::ChoiceProperty@{aetycoon::ChoiceProperty}}
\subsubsection[{get\_\-choices}]{\setlength{\rightskip}{0pt plus 5cm}def aetycoon.ChoiceProperty.get\_\-choices (
\begin{DoxyParamCaption}
\item[{}]{self}
\end{DoxyParamCaption}
)}}
\label{classaetycoon_1_1_choice_property_afe3ec218220685bfcd03fe7f312596a9}
\begin{DoxyVerb}Gets a list of values which may be assigned to this property.\end{DoxyVerb}
 

The documentation for this class was generated from the following file:\begin{DoxyCompactItemize}
\item 
aetycoon/\_\-\_\-init\_\-\_\-.py\end{DoxyCompactItemize}
